package com.weather.controller;

import com.weather.domain.WeatherResponse;
import com.weather.service.WeatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/weather")
public class WeatherController {

    @Autowired
    private WeatherService weatherService;

    // 支持通过查询参数 ?city=城市ID 访问
    @GetMapping
    public WeatherResponse getWeather(@RequestParam("city") String cityId) {
        return weatherService.queryWeatherForUser(cityId);
    }
}
